Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3-pu2rile #10

Merged
merged 4 commits into from
Jul 10, 2024
Merged

3-pu2rile #10

merged 4 commits into from
Jul 10, 2024

Conversation

pu2rile
Copy link
Collaborator

@pu2rile pu2rile commented Apr 2, 2024

πŸ”— 문제 링크

https://www.acmicpc.net/problem/2941

βœ”οΈ μ†Œμš”λœ μ‹œκ°„

30λΆ„

✨ μˆ˜λ„ μ½”λ“œ

  • 문제 μš”μ•½

단어λ₯Ό μž…λ ₯λ°›κ³ , ν•΄λ‹Ή λ¬Έμžμ—΄μ΄ λͺ‡ 개의 ν¬λ‘œμ•„ν‹°μ•„ μ•ŒνŒŒλ²³μœΌλ‘œ 이루어져 μžˆλŠ”μ§€ 좜λ ₯ν•œλ‹€.

dΕΎλŠ” 무쑰건 ν•˜λ‚˜μ˜ μ•ŒνŒŒλ²³μœΌλ‘œ 쓰이고, d와 ΕΎκ°€ λΆ„λ¦¬λœ κ²ƒμœΌλ‘œ 보지 μ•ŠλŠ”λ‹€.

λͺ©λ‘μ— μ—†λŠ” μ•ŒνŒŒλ²³μ€ ν•œ κΈ€μžμ”© μ„Όλ‹€.

ex) ljes=njak은 ν¬λ‘œμ•„ν‹°μ•„ μ•ŒνŒŒλ²³ 6개(lj, e, Ε‘, nj, a, k)둜 이루어져 μžˆλ‹€.

스크란샷 2024-04-03 α„‹α…©α„Œα…₯ᆫ 12 42 15
  • 풀이 κ³Όμ •
  1. λ³€κ²½(λŒ€μ²΄) 문자λ₯Ό ν•˜λ‚˜μ˜ 리슀트 change[]둜 μ •μ˜ν•œλ‹€.
  2. input()으둜 λ¬Έμžμ—΄ str을 μž…λ ₯λ°›λŠ”λ‹€.
  3. λ°˜λ³΅λ¬Έμ„ 톡해 str λ¬Έμžμ—΄μ— change 리슀트 λ‚΄ μš”μ†Œμ™€ 같은 문자λ₯Ό λ°œκ²¬ν•˜λ©΄ 'a'둜 μΉ˜ν™˜ν•œλ‹€. .replace() μ‚¬μš©.
    => 'dz='와 같은 문자λ₯Ό ν•˜λ‚˜μ˜ ν¬λ‘œμ•„ν‹°μ•„ μ•ŒνŒŒλ²³μœΌλ‘œ 계산해야 ν•˜κΈ° λ•Œλ¬Έμ΄λ‹€.
  4. 반볡문 νƒˆμΆœ ν›„ str λ¬Έμžμ—΄μ˜ 길이λ₯Ό 좜λ ₯(len() μ‚¬μš©)ν•˜λ©΄ μ•ŒνŒŒλ²³μ˜ μˆ˜κ°€ κ³„μ‚°λœλ‹€.

πŸ–₯️ μ½”λ“œ

change = ['c=','c-','dz=','d-','lj','nj','s=','z=']
str = input()
for n in change: #changeμ—μ„œ ν•˜λ‚˜μ”© 루프 돌며 
  str = str.replace(n, 'a') #strκ³Ό 같은 문자λ₯Ό λ°œκ²¬ν•˜λ©΄ ν•΄λ‹Ή 문자λ₯Ό a으둜 μΉ˜ν™˜
print(len(str)) #str의 길이

πŸ“š μƒˆλ‘­κ²Œ μ•Œκ²Œλœ λ‚΄μš©

처음 문제λ₯Ό μ‹œλ„ν–ˆμ„ λ•Œ 이와 같은 μš”μƒν•œ μ½”λ“œλ₯Ό μž‘μ„±ν–ˆμ—ˆλŠ”λ°...

num=0
croatia = ['lj','e','s=','nj','a','k']
print(croatia)

if 'c=' in croatia:
  num+=1
if 'c-' in croatia:
  num+=1
if 'dz=' in croatia:
  num+=1
if 'd-' in croatia:
  num+=1
if 'lj' in croatia:
  num+=1
if 'nj' in croatia:
  num+=1
if 's=' in croatia:
  num+=1
if 'z=' in croatia:
  num+=1
  ??

λ‹€μ‹œ μ°¨κ·Όμ°¨κ·Ό 생각해 λ³΄λ‹ˆ 리슀트 μš”μ†Œλ₯Ό 잘λͺ» λ„£μ–΄μ„œ ν’€κ³  μžˆλ”λΌκ΅¬μš”...γ…Žγ…Ž;;
μ•„λ¬΄νŠΌ!
문제λ₯Ό 톡해 replaceν•¨μˆ˜μ™€ lenν•¨μˆ˜λ₯Ό μ˜€λžœλ§Œμ— 써 λ³΄λ©΄μ„œ λ³΅μŠ΅λ„ 되고 μ’‹μ•˜μŠ΅λ‹ˆλ‹Ή
λ‹€λ“€ 이제 μ‹œν—˜ κΈ°κ°„ μ‹œμž‘λ˜μ…¨μ„ 텐데... νŒŒμ΄νŒ…ν•΄μš”... 같이... μ•„μžμ•„μž

Copy link
Member

@oesnuj oesnuj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 μ˜ˆμ „μ— 이 문제λ₯Ό ν’€μ—ˆλŠ”λ° λ„ν˜„λ‹˜ 처음 ν’€μ΄μ²˜λŸΌ if - else둜 μ­‰ λ‚˜λˆ μ„œ countν•˜λ©΄μ„œ ν’€μ—ˆλŠ”λ° μ•ŒνŒŒλ²³ ν•˜λ‚˜λ‘œ μΉ˜ν™˜ν•˜λŠ” 쒋은 방법이 μžˆμ—ˆλ„€μš”πŸ˜―
μƒˆλ‘œμš΄ 접근법 ν•˜λ‚˜ μ•Œμ•„κ°€μš”!! PR μˆ˜κ³ ν•˜μ…¨μ–΄μš”~

Copy link
Collaborator

@suhyun113 suhyun113 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ν¬λ‘œμ•„ν‹°μ•„ μ•ŒνŒŒλ²³ 문제,,,μ–΄λ”˜κ°€ 낯이 읡닀 ν–ˆλŠ”λ° μ €λ²ˆμ— 풀지 말지 κ³ λ―Όν–ˆλ˜ λ¬Έμ œμ˜€λ„€μš”..γ…Žγ…Ž κ²°κ΅­ 고민만 ν•˜λ‹€κ°€ 풀지 μ•Šμ•˜λŠ”λ°, μ΄λ ‡κ²Œ ν’€μ–΄λ³΄κ²Œ λ˜λ‹€λ‹ˆ!! λ„ν˜„λ‹˜ 풀이 과정을 λ³΄λ©΄μ„œ 슀슀둜 μ½”λ“œλ₯Ό κ΅¬ν˜„ν•΄ λ³΄μ•˜λŠ”λ°, μ„€λͺ…을 잘 ν•΄μ£Όμ…”μ„œ κ·ΈλŸ°μ§€ 이해가 잘 λ˜μ—ˆμŠ΅λ‹ˆλ‹€. 생각보닀 μ½”λ“œκ°€ κ°„λ‹¨ν•΄μ„œ λ†€λžμ–΄μš”. νŠΉμ΄ν–ˆλ˜ 점은 ν¬λ‘œμ•„ν‹°μ•„ μ•ŒνŒŒλ²³μ„ λ°œκ²¬ν•˜λ©΄ κ·Έ 문자λ₯Ό λ‹€λ₯Έ 문자둜 μΉ˜ν™˜ν•œλ‹€λŠ” κ²ƒμ΄μ—ˆμ–΄μš”! 이 μ½”λ“œ 덕뢄에 ν™•μ‹€νžˆ μ½”λ“œκ°€ 간결해지고 μ’€ 더 효율적인 것 κ°™μ•„ 이런 방법도 μžˆλ‹€λŠ” 사싀을 μ•Œκ²Œλ˜μ–΄ μœ μ΅ν–ˆμŠ΅λ‹ˆλ‹€. PR μž‘μ„± μˆ˜κ³ ν•˜μ…¨μŠ΅λ‹ˆλ‹€.

@Ghdrn1399
Copy link
Contributor

이번주 μ•Œκ³ λ¦¬λ“œλ―Έ μž‘μ„±ν•˜μ‹œλŠλΌ 수고 ν•˜μ…¨μŠ΅λ‹ˆλ‹€. ν¬λ‘œμ•„ν‹°μ•„ μ•ŒνŒŒλ²³ μΌμ’…μ˜ 문자 νŒ¨ν„΄ 맀칭? λΆ€λ₯˜μ˜ λ¬Έμ œμ˜€λ˜κ²ƒ 같은데 μŠ€νƒμ„ μ΄μš©ν•΄μ„œ ν’€μ—ˆλ˜ 기얡은 λ‚˜λŠ”λ° μƒˆλ‘œμš΄ μ½”λ“œλ‘œ μ§œμ—¬μ§„ 문제 풀이λ₯Ό λ³΄λ‹ˆ ν₯λ―Έλ‘­λ„€μš”! μƒˆλ‘­κ²Œ μ•Œμ•„κ°‘λ‹ˆλ‹€~

@pu2rile pu2rile merged commit bf24871 into main Jul 10, 2024
@pu2rile pu2rile deleted the 3-pu2rile branch July 10, 2024 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants